<?
layout("/inc/layout.html",{title:sysTitle}){
?>
<script type="text/javascript" src="static/echarts-2.2.7/doc/example/www/js/echarts.js"></script>
<script type="text/javascript" src="static/utf8-jsp/ueditor.config.js"></script>
<script type="text/javascript" src="static/utf8-jsp/ueditor.all.js"></script>

<meta name="viewport" content="width=device-width, initial-scale=1" />
<div id="page-wrapper">
	<!--BEGIN TITLE & BREADCRUMB PAGE-->
	<div id="title-breadcrumb-option-demo" class="page-title-breadcrumb">
		<div class="page-header pull-left">
			<div class="page-title">叙词表管理</div>
		</div>
		<ol class="breadcrumb page-breadcrumb pull-left">
			<li><i class="fa fa-home"></i>&nbsp;<a href="main.html">首页</a>&nbsp;&nbsp;<i
				class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
			<li>词表管理&nbsp;&nbsp;<i class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
			<li class="active">叙词表管理</li>
		</ol>

		<div class="clearfix"></div>
	</div>
	<!--END TITLE & BREADCRUMB PAGE-->
	<!--BEGIN CONTENT-->
	<div class="page-content" style="width:auto; overflow: auto;">
		<div class="row">
			<div class="col-lg-12" style="margin-top:-12px; margin-bottom: -10px;">
				<div class="panel" style="overflow: auto;">
					<span style="padding-top:5px; float: left;">
						<b style="padding-left:5px;"" >叙词表分类：</b>
						<select data-toggle="dropdown" id="wordClasses" class="btn btn-danger dropdown-toggle" style="width :150px;">
							<?for(twm in thesauriWordModule){?>
								<option value="${twm.id}" ${twm.selected}>${twm.nameZh}</option>
							<?}?>
						</select>
					</span>
					<span class="demo-btn" style="padding-top:5px; float: right;">
						<button type="button" class="btn btn-sm btn-info btn-outlined " onclick="uploadFile()">导入</button>
						<button type="button" class="btn btn-sm btn-info btn-outlined " onclick="exportWord()">导出</button>
						<button type="button" class="btn btn-sm btn-info btn-outlined " onclick="generalWordCategoryzTree()">范畴管理</button>
						<button id="showDataValue" value="0" onclick="tableDiv()" type="button" class="btn btn-sm btn-info btn-outlined">图形化管理叙词表</button>
						<!-- <button type="button" onclick="category()" class="btn btn-sm btn-info btn-outlined">范畴导出</button>
						<button type="button" onclick="vocabulary()" class="btn btn-sm btn-info btn-outlined">全库数据导出</button>
						<button type="button" onclick="scope()" class="btn btn-sm btn-info btn-outlined">下载范畴导出说明</button>
						<button type="button" onclick="note()" class="btn btn-sm btn-info btn-outlined">下载全库导出说明</button> -->
					</span>
				</div>
			</div>

			<div id="tuXingHuaShow" class="col-lg-12">
				<div class="panel" style="height: 670px;width:auto;">
					<div class="panel-heading">
						数据列表 <span class="subtitle">展示词表数据列表，点击可编辑词表具体条目信息。</span>
						 <span
							class="demo-btn"
							style="float: right; margin-right: -8px; margin-top: -2px;">
							<button type="button" onclick="addEditThesauriWord2(0)" class="btn btn-sm btn-danger btn-outlined">新建款目词</button>
						</span>
					</div>
					<div class="page-content">
						<div style="min-height: auto;min-width: auto; ">
							<div style="height: 605px; width:auto; margin-top: -15px"
								id="main" class="main"></div>
						</div>
					</div>
				</div>
			</div>
			
			<div id="lieBiaoShow" class="col-lg-12">
				<div class="panel" style="height: auto;width:auto;">
					<div class="panel-heading">
						数据列表 <span class="subtitle">展示词表数据列表，点击可编辑词表具体条目信息。</span>
						<span class="subtitle" style="float: right;" id="count"></span> 
					</div>
					<div class="page-content">
						<div class="panel-body pan " style="width:auto; overflow: auto;">
							<div>
								<div class="col-md-6">
									<div class="input-icon">
										<input id="nameZh2" type="text" placeholder="主题款目词"
											class="form-control" />
										<p id="nameZhTiShi"></p>
									</div>
								</div>
								<div class="col-md-2" style="display: none;" id="selectCategory">
									<div class="input-icon" style="margin-top: 10px;">
									当前选择范畴：<span id="fcInput" name="fcInput"></span>
									<!-- <input  type="text" placeholder="范畴" class="form-control" value="" /> -->
									<input type="hidden" id="fc"/>
									<!-- <p id="fcDiv"></p>
									<div class="input-icon" id="fcDiv">
									</div> -->	
									</div>
								</div>
								<div style="float: right;margin-bottom: 10px;">
									<button type="button" class="btn btn-primary btn-blue"
										onclick="preciseAllthesauriWordReferenceLieBiao('1')">精确搜索</button>
									&nbsp;
									<button type="button" class="btn btn-primary btn-blue"
										onclick="findAllthesauriWordReferenceLieBiao('1')">模糊搜索</button>
									&nbsp;
									<button type="button" class="btn btn-primary btn-blue"
										onclick="addEditThesauriWord2('0')">新建款目词</button>
											&nbsp;
									<div style="margin-top :10px;">
										<button type="button" class="btn btn-primary btn-blue"
										onclick="selectThesauriWord2()">根据范畴查询</button>
										&nbsp;
										<button type="button" class="btn btn-primary btn-blue"
										onclick="deleteThesauriWord2()">清空范畴</button>
										&nbsp;
									</div>
								</div>
							</div>
							<div class="table-container">
								<table
									class="table table-hover table-striped table-bordered table-advanced tablesorter">
									<thead>
										<tr id="trTitle">
											
										</tr>
									</thead>
									<tbody id="lieBiaoThesauriWordReference">
									</tbody>
								</table>
								<div id="page3" style="text-align: center; margin-bottom: -130px;"></div>
								<div id="dataNull2" class="panel-body"style="height: 90px; line-height: 50px;margin-top: 100px;" align="center">
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			
			<input type="hidden"  id="thIds" value=""/>
			<textarea id="uploadImage" name="uploadImage" ></textarea>
			
		</div>
		<!--END CONTENT-->
		 <form action="downloadNote.do" method="post" name="aa" target="_blank"></form>
		 <form action="downloadScope.do" method="post" name="bb" target="_blank"></form>
	</div>
</div>
	<SCRIPT type="text/javascript">
	var curr=1;
	var relevanceCurr=1;
	function getRelevanceCurr(){
		return relevanceCurr;
	}
		
	var thesauriWordId;
	var thesauriWordPid;
	function tableDiv(){
		var showDataValue = $("#showDataValue").val();
		if(showDataValue == '0'){
			$("#showDataValue").html("列表式管理叙词表");
			$("#tuXingHuaShow").hide();
			$("#lieBiaoShow").show();
			findAllthesauriWordReferenceLieBiao(1);
			var path ="/";
			var expires = new Date();  
		    expires.setTime(expires.getTime() + 7 * 3600000 * 24);  
		    //path=/，表示cookie能在整个网站下使用，path=/temp，表示cookie只能在temp目录下使用  
		    path = path == "" ? "" : ";path=" + path;  
		    //GMT(Greenwich Mean Time)是格林尼治平时，现在的标准时间，协调世界时是UTC  
		    //参数days只能是数字型  
		    var _expires = (typeof days) == "string" ? "" : ";expires=" + expires.toUTCString();  
		    document.cookie = "tableType=1" + _expires + path;
		    $("#showDataValue").val('1');
		}else{
				$("#showDataValue").html("图形化管理叙词表");
				$("#tuXingHuaShow").show();
				$("#lieBiaoShow").hide();
				tuxinghua($("#wordClasses").val());	
				var path ="/";
				var expires = new Date();  
			    expires.setTime(expires.getTime() + 7 * 3600000 * 24);  
			    //path=/，表示cookie能在整个网站下使用，path=/temp，表示cookie只能在temp目录下使用  
			    path = path == "" ? "" : ";path=" + path;  
			    //GMT(Greenwich Mean Time)是格林尼治平时，现在的标准时间，协调世界时是UTC  
			    //参数days只能是数字型  
			    var _expires = (typeof days) == "string" ? "" : ";expires=" + expires.toUTCString();  
			    document.cookie = "tableType=0" + _expires + path;
			    $("#showDataValue").val('0');
		}
	}
	$(function() {
		//tuxinghua($("#wordClasses").val());
			
		_editor = UE.getEditor('uploadImage');
	    _editor.ready(function (){
	        //设置编辑器不可用(事实上不可以设置不可用...所以注释掉,以观后效)
	        _editor.setDisabled();
	        //隐藏编辑器,因为只使用上传功能
	        _editor.hide();
	        //侦听图片上传
	  	 	_editor.addListener('beforeInsertImage',function(t,arg){
	  	 		
	        });
	        //侦听文件上传
		   	 _editor.addListener('afterUpfile',function(t,arg){
		   	 	//for(var i=0;i<arg.length;i++){
	  	 			importWord(arg[0].url);
	  	 		//}
		   	 });
	   });
			
	});
	/**实现功能，保存用户的登录信息到cookie中。当登录页面被打开时，就查询cookie**/  
	window.onload = function(){  
		var path ="/";
	    var tableType = getCookieValue("tableType"); 
	    if('' != tableType &&  null != tableType && undefined != tableType){
	    	if(tableType == '0'){
	    		$("#showDataValue").html("图形化管理叙词表");
				$("#tuXingHuaShow").show();
				$("#lieBiaoShow").hide();
				$("#showDataValue").val('0');
				tuxinghua($("#wordClasses").val());	
	    		tableType = 0;
	    	}else{
	    		$("#showDataValue").html("列表式管理叙词表");
				$("#tuXingHuaShow").hide();
				$("#lieBiaoShow").show();
				$("#showDataValue").val('1');
				findAllthesauriWordReferenceLieBiao(1);
	    		tableType = 1;
	    	}
	    }else{
	    	$("#lieBiaoShow").hide();
	    	$("#showDataValue").val('0');
	    	tuxinghua($("#wordClasses").val());	
	    	tableType = 0 ;
	    }
	    var expires = new Date();  
	    expires.setTime(expires.getTime() + 7 * 3600000 * 24);  
	    //path=/，表示cookie能在整个网站下使用，path=/temp，表示cookie只能在temp目录下使用  
	    path = path == "" ? "" : ";path=" + path;  
	    //GMT(Greenwich Mean Time)是格林尼治平时，现在的标准时间，协调世界时是UTC  
	    //参数days只能是数字型  
	    var _expires = (typeof days) == "string" ? "" : ";expires=" + expires.toUTCString();  
	    document.cookie = "tableType=" + tableType + _expires + path;
	} 
	function getCookieValue(name){  /**获取cookie的值，根据cookie的键获取值**/  
	    //用处理字符串的方式查找到key对应value  
	    var name = escape(name);  
	    //读cookie属性，这将返回文档的所有cookie  
	    var allcookies = document.cookie;         
	    //查找名为name的cookie的开始位置  
	    name += "=";  
	    var pos = allcookies.indexOf(name);      
	    //如果找到了具有该名字的cookie，那么提取并使用它的值  
	    if (pos != -1){                                             //如果pos值为-1则说明搜索"version="失败  
	        var start = pos + name.length;                  //cookie值开始的位置  
	        var end = allcookies.indexOf(";",start);        //从cookie值开始的位置起搜索第一个";"的位置,即cookie值结尾的位置  
	        if (end == -1) end = allcookies.length;        //如果end值为-1说明cookie列表里只有一个cookie  
	        var value = allcookies.substring(start,end); //提取cookie的值  
	        return (value);                           //对它解码        
	    }else{  //搜索失败，返回空字符串  
	        return "";  
	    }  
	}  
	
	 $(document).ready(function(){
		  $("#wordClasses").change(function(){
		  	$("#nameZh2").val("");
		  	$("#fcInput").html("");
			$("#fc").val("");
			$("#selectCategory").hide();
		    tuxinghua(this.value);
		    findAllthesauriWordReferenceLieBiao(1);
		  });
		});
	function tuxinghua(tuClasses){
	thesauriWordId=$("#thIds").val();
		// 路径配置
		require.config({
			paths : {
				echarts : 'static/echarts-2.2.7/build/dist'
			}
		});

		// 使用
		require([ 'echarts', 'echarts/chart/force' // 使用柱状图就加载bar模块，按需加载
		], function(ec) {
			var datas;
			// 基于准备好的dom，初始化echarts图表
			var myChart = ec.init(document.getElementById('main'));
				$.ajax({
				type : "post",
				url : "./findthesauriWordReferenceTuXingHua.do",
				data : {
					"thesauriWordId" : thesauriWordId,
					"wordClasses" : tuClasses
				},
				dataType : "json",
				async : false,
				success : function(data) {
					datas = data;
					//alert(JSON.stringify(data));
				},
				error : function(data) {
						//parent.layer.msg('请选择款目词');
				}
			});
			var option = {
				title : {
					text : '关系',
					subtext : '',
					x : 'right',
					y : 'bottom'
				},
				tooltip : {
					trigger : 'item',
					formatter : '{a} : {b}'
				},
				toolbox : {
					show : true,
					feature : {
						restore : {
							show : true
						},
						magicType : {
							show : false,
							type : [ 'force', 'chord' ]
						},
						saveAsImage : {
							show : true
						}
					}
				},
				legend : {
					x : 'left',
					data : [ '核心概念','所属分类', '所属分类添加','关联项']
				},
				series : [ {
					type : 'force',
					name : "",
					ribbonType : false,
					categories : [ {
						name : '核心概念'
					}, {
						name : '所属分类'
					}, {
						name : '所属分类添加'
					}, {
						name : '关联项'
					}],
					itemStyle : {

						normal : {
							label : {
								show : true,
								textStyle : {
									color : '#333'
								}
							},
							nodeStyle : {
								brushType : 'both',
								borderColor : 'rgba(255,215,0,0.4)',
								borderWidth : 1
							},
							linkStyle : {
								type : 'curve' //连接线类型
							}
						},
						emphasis : {
							label : {
								show : false,
							//textStyle: null      // 默认使用全局文本样式，详见TEXTSTYLE
							},
							nodeStyle : {
							//r: 30
							},
							linkStyle : {}
						}
					},
					useWorker : false,
					minRadius : 15,
					maxRadius : 25,
					gravity : 1.1,
					scaling : 1.1,
					linkSymbol : 'arrow', //链接线 是  箭头
					roam : 'move',
					nodes :datas,
					links :datas

					//source 连接起点（来源） target  连接终点（目标）
					
				} ]
			};
			var ecConfig = require('echarts/config');
			function focus(param) {
				var data = param.data;
				var links = option.series[0].links;
				var nodes = option.series[0].nodes;
				if (data.source !== undefined && data.target !== undefined) { //点击的是边
					var sourceNode = nodes.filter(function(n) {
						return n.name == data.source
					})[0];
					var targetNode = nodes.filter(function(n) {
						return n.name == data.target
					})[0];
					console.log("选中了边 " + sourceNode.name + ' -> '
							+ targetNode.name + ' (' + data.weight + ')');
				} else { // 点击的是点
					console.log("选中了" + data.name + '(' + data.value + ')');
				}
			}

			myChart.on('click', function(params) {
				var kmClasses = $("#wordClasses").val();
				if(params.data.category==0){
					parent.layer.open({
						type : 2,
						area : [ '900px', '600px' ],
						scrollbar : false,
						shadeClose : true,
						fix : false, //不固定
						title : '款目参照项',
						//maxmin : true,  
						skin : 'layui-layer-rim', //加上边框
						btn : [ '确认','关闭' ],
						content : [ "word-thesaurus-find-ReferenceSave.html?thesauriWordId="+thesauriWordId+"&source="+null+"&category="+params.data.category+"&winName="+window.name+"&wordClasses="+kmClasses, 'no' ],
						yes : function(index, layer) {
							var iframeWin = parent.window[layer.find('iframe')[0]['name']];
							iframeWin.queRen();
						},
						cancel : function(index) {
						}
					});
				} else if(params.data.category==2 && thesauriWordId!=null && thesauriWordId!=""){
					parent.layer.open({
						type : 2,
						area : [ '900px', '600px' ],
						scrollbar : false,
						shadeClose : true,
						fix : false, //不固定
						title : '款目参照项',
						//maxmin : true,  
						skin : 'layui-layer-rim', //加上边框
						btn : [ '确认','关闭' ],
						content : [ "word-thesaurus-find-ReferenceSave.html?thesauriWordId="+thesauriWordId+"&source="+params.data.source+"&category="+params.data.category+"&winName="+window.name+"&wordClasses="+kmClasses, 'no' ],
						yes : function(index, layer) {
							var iframeWin = parent.window[layer.find('iframe')[0]['name']];
							iframeWin.queRen();
						},
						cancel : function(index) {
						}
					});
				}else if(params.data.category==2 &&(thesauriWordId==null || thesauriWordId=="")){
					layer.msg('请选择主题款目词');
				}else if(params.data.category==3){
					addEditThesauriWord(params.data.id,params.data.thesauriWordId,params.data.source);
				}
			});
			// 为echarts对象加载数据 
			myChart.setOption(option);
			window.onresize = myChart.resize; //自适应大小
		});
}

		var id;
		var twrId;
		
		function getThesauriWordId() {
			return id;
		}
		function getTwrId() {
			return twrId;
		}
		var source;
		function getsource() {
			return source;
		}
		//清空
		function deleteThesauriWord2(){
			$("#fcInput").html("");
			$("#fc").val("");
			$("#selectCategory").hide();
			findAllthesauriWordReferenceLieBiao(curr);
		}
	//导入
	function uploadFile() {
		var myFiles = _editor.getDialog("attachment");
	   	myFiles.open();
	}
		function importWord(urlFile){
		$.ajax({
			type : "post",
			url : "./importWord.do",
			data : {
				"urlFile" : urlFile
			},
			dataType : "json",
			traditional : true,
			success : function(data) {
				if(data[0].data == 'yes'){
					layer.msg('导入成功');
					window.location.reload();
				}else if(data[0].data == 'type'){
					layer.msg('请上传正确的xml、xls或者xlsx格式文件!');
				}else{
					layer.msg('导入失败！');
				}
			},
			error : function(data) {
				alert("请求失败");
			}
		});
	}
		//根据范畴查询
			function selectThesauriWord2() {
			parent.layer.open({
				type : 2,
				area : [ '700px', '640px' ],
				fix : false, //不固定
				scrollbar : false,
				shadeClose : true,
				title : '范畴管理',
				//maxmin : true,  
				skin : 'layui-layer-rim', //加上边框
				btn : [ '确认','关闭' ],
				content : [ "select_thesauriWordCategory_zTree.html", 'no' ],
				yes : function(index, layer) {
						var iframeWin = parent.window[layer.find('iframe')[0]['name']];
						iframeWin.Page();
					},
				cancel : function(index) {
				}
			});
		}
		function addEditThesauriWord(lid,tId,sources) {
			var addwordClasses = $("#wordClasses").val();
			id = lid;
			twrId=tId;
			source=sources;
			var close_button='0';
			parent.layer.open({
				type : 2,
				area : [ '700px', '640px' ],
				scrollbar : false,
				shadeClose : true,
				fix : false, //不固定
				title : '主题款目词表',
				//maxmin : true,  
				skin : 'layui-layer-rim', //加上边框
				btn : ['保存','删除关联项', '关闭' ],
				content : [ "word-thesauriWord-addEdit.html?winName="+window.name+"&source="+relevanceCurr+"&addwordClasses="+addwordClasses, 'no' ],
				yes : function(index, layer) {
					var iframeWin = parent.window[layer.find('iframe')[0]['name']];
					iframeWin.Page();
				},
				btn2 : function(index, layer) {
					close_button='1';
					var iframeWin = parent.window[layer.find('iframe')[0]['name']];
					iframeWin.delThesauriWordReference();
				},
				cancel : function(index) {
					if(close_button=='0'){
						parent.layer.close(index);
					}
					return false;
				},
			});
		}
		function getShanChu(){
			return 0;
		}
		function addEditThesauriWord2(lid) {
			var addwordClasses = $("#wordClasses").val();
			id = lid;
			parent.layer.open({
					type : 2,
					area : [ '700px', '640px' ],
					scrollbar : false,
					shadeClose : true,
					fix : false, //不固定
					title : '主题款目词表',
					//maxmin : true,  
					skin : 'layui-layer-rim', //加上边框
					btn : ['保存','关闭 '],
					content : [ "word-thesauriWord-addEdit.html?winName="+window.name+"&source="+relevanceCurr+"&addwordClasses="+addwordClasses, 'no' ],
					yes : function(index, layer) {
						var iframeWin = parent.window[layer.find('iframe')[0]['name']];
						iframeWin.Page();
					},
					cancel : function(index) {
					}
				});
	  }
		function queryJunior(juniorid) {
			parent.layer.open({
					type : 2,
					area : [ '600px', '500px' ],
					scrollbar : false,
					shadeClose : true,
					fix : false, //不固定
					title : '层级',
					//maxmin : true,  
					skin : 'layui-layer-rim', //加上边框
					btn : ['关闭 '],
					content : [ "word-thesauriWord-junior.html?winName="+window.name+"&id="+juniorid, 'no' ],
					cancel : function(index) {
					}
				});
	  }

		//模糊
		function findAllthesauriWordReferenceLieBiao(curr,fc,fcname) {
		//a=encodeURI(a,"utf-8");  
			if(fc != "" && fc != null){
				$("#fcInput").html(fcname);
				$("#fc").val(fc);
				$("#selectCategory").show();
			}
			$.getJSON(
				"./findAllthesauriWordReferenceLieBiao.do",
				{
					page : curr || 1,
					text : $("#nameZh2").val(),
					fc	:$("#fc").val(),
					type :0,
					wordClasses : $("#wordClasses").val()
				},
				function(res) {
					//此处仅仅是为了演示变化的内容
					var titleKey = res.keys[0];
					var titleText='<th width="5%">序号</th><th width="10%">主题款目词</th><th width="10%">英文名称</th>';
					for(var tk in titleKey){
					    titleText += '<th >'+titleKey[tk]+'</th>';
					} 
					titleText += '<th width="6%">可操作</th>';
					$("#trTitle").html(titleText);
					var lieBiaoThesauriWordReference = "";
					$("#lieBiaoThesauriWordReference").html("");
					if (res.listsize > 0) {
						$("#dataNull2").html("");
					} else {
						$("#dataNull2").html("<span class='subtitle' style='font-size: 15px;'>数据为空!</span>");
						$("#trTitle").html("");
					}
					var map = {};
					for ( var j = 0; j < res.listsize; j++) {
						for ( var i = 0; i < res.result[j].countsize; i++) {
							var values = map[res.result[j].thesauriWordReference[i].referenceRelationLabel];
							if(values != null && '' != values && undefined != values){
								if(map['count'+res.result[j].thesauriWordReference[i].referenceRelationLabel] < 3 ){
									map[res.result[j].thesauriWordReference[i].referenceRelationLabel] = map[res.result[j].thesauriWordReference[i].referenceRelationLabel]
											+"<button type='button' class='btn btn-default btn-green btn-xs' onclick=addEditThesauriWord('"
											+ res.result[j].thesauriWordReference[i].referenceWordId+"','"+res.result[j].thesauriWordId +"','"+res.result[j].thesauriWordReference[i].referenceRelationLabel+"')  style='margin-top: 5px; margin-right: 5px;'>"
											+ res.result[j].thesauriWordReference[i].referenceWordName
											+ "</button>";
								}
								map['count'+res.result[j].thesauriWordReference[i].referenceRelationLabel] =map['count'+res.result[j].thesauriWordReference[i].referenceRelationLabel]+1;
							}else{
								map[res.result[j].thesauriWordReference[i].referenceRelationLabel] = "<button type='button' class='btn btn-default btn-green btn-xs' onclick=addEditThesauriWord('"
											+ res.result[j].thesauriWordReference[i].referenceWordId+"','"+res.result[j].thesauriWordId +"','"+res.result[j].thesauriWordReference[i].referenceRelationLabel+"')  style='margin-top: 5px; margin-right: 5px;'>"
											+ res.result[j].thesauriWordReference[i].referenceWordName
											+ "</button>";
								map['count'+res.result[j].thesauriWordReference[i].referenceRelationLabel] =1;
							}
						}
						lieBiaoThesauriWordReference += ""
								+ "<tr>"
								+ "<td ><div id='youxuanY' class='panel-body'  align='center'>"
								+ "<span >"
								+ (j + 1)
								+ "</span>"
								+ "</div></td>"
								+ "<td>"
								+ "<div id='youxuanY' class='panel-body'  align='center'>"
								+ "<div class='demo-btn'>"
								+ "<button type='button' class='btn  btn-warning ' onclick=thesauriWordReferenceAddEdit('"
											+ res.result[j].thesauriWordId
											+ "') style='margin-top: 5px; margin-right: 5px;'>"
											+ res.result[j].thesauriWordName
											+ "</button>"
								+ "</div>" + "</div>"
								+ "</td>"
								+ "<td>"
								+ "<div id='youxuanY' class='panel-body'  align='center'>"
								+ "<div class='demo-btn'>";
								if(res.result[j].wordEnglish != null && res.result[j].wordEnglish !=''){
									lieBiaoThesauriWordReference +=  "<button type='button' class='btn  btn-warning ' onclick=thesauriWordReferenceAddEdit('"
																+ res.result[j].thesauriWordId
																+ "') style='margin-top: 5px; margin-right: 5px;'>"
																+ res.result[j].wordEnglish
																+ "</button>";
								}else{
									lieBiaoThesauriWordReference +=  "<button type='button' class='btn  btn-warning ' style='margin-top: 5px; margin-right: 5px;'>无</button>";
								}
								lieBiaoThesauriWordReference +=  "</div>" + "</div>"
								+ "</td>";
								for(var tk in titleKey){
									if(map[tk] != null && '' != map[tk] && undefined != map[tk]){
										lieBiaoThesauriWordReference +="<td id='"+tk+"_"+res.result[j].thesauriWordId+"'>"+map[tk]+"<button type='button' class='btn btn-default btn-blue btn-xs' onclick=wtFindReferenceSave('"+res.result[j].thesauriWordId+"','"+tk+"') style='margin-top: 5px; margin-right: 5px;'>+</button>";
									}else{
										lieBiaoThesauriWordReference +="<td id='"+tk+"_"+res.result[j].thesauriWordId+"'><button type='button' class='btn btn-default btn-blue btn-xs' onclick=wtFindReferenceSave('"+res.result[j].thesauriWordId+"','"+tk+"') style='margin-top: 5px; margin-right: 5px;'>+</button>";
									}
								   
									if (map['count'+tk] > 3) {
										lieBiaoThesauriWordReference += "<button type='button' id='button_"+tk+"_"+res.result[j].thesauriWordId+"' class='btn btn-default btn-xs' name='bianShow' onclick=shouOrHeid('"+tk+"','"+res.result[j].thesauriWordId+"') style='margin-top: 5px; margin-right: 5px; float: right;'>展开</button>";
									}
									lieBiaoThesauriWordReference += "</td >";
								} 
						
	  				lieBiaoThesauriWordReference += "<td>"
								+ "<div  align='center'>"
								+ "<button type='button' style='margin-bottom: 2px;' class='btn btn-default btn-xs'onclick=delThesauriWord("
								+ res.result[j].thesauriWordId
								+ ") >删除</button>"
								/* + "<button type='button'  style='margin-bottom: 2px;'  class='btn btn-default btn-xs'onclick=addEditThesauriWord2("
								+ res.result[j].thesauriWordId
								+ ") >编辑款目词</button>" */
								+ "<button type='button'  style='margin-bottom: 2px;'  class='btn btn-default btn-xs'onclick=thesauriWordReferenceAddEdit("
								+ res.result[j].thesauriWordId
								+ ") >编辑</button>"
								+ "<button type='button'  style='margin-bottom: 2px;'  class='btn btn-default btn-xs' onclick=releaseFindThesauriWord("
								+ res.result[j].thesauriWordId
								+ ") >发布</button>"
								+ "</div>" + "</td>"
								+ "</tr>";
								map={};
					}
	
					$("#lieBiaoThesauriWordReference").append(
							lieBiaoThesauriWordReference);
							$("#count").html("词表总数:"+res.count);
					//$("[name=bianShow]").hide();
					laypage({
						cont : document.getElementById('page3'), //容器。值支持id名、原生dom对象，jquery对象,
						pages : res.pageSize, //总页数
						skip : true, //是否开启跳页
						skin : 'molv', //加载内置皮肤，也可以直接赋值16进制颜色值，如:#c00
						curr : curr || 1,
						last: res.pageSize,
						groups : 6,//连续显示分页数
						jump : function(obj, first) { //触发分页后的回调
							if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
								findAllthesauriWordReferenceLieBiao(obj.curr);
								curr = obj.curr;
								relevanceCurr=obj.curr;
							}
						}
					});
				});
		};
		//精确
		function preciseAllthesauriWordReferenceLieBiao(curr,fc,fcname) {
			if(fc != "" && fc != null){
				$("#fcInput").html(fcname);
				$("#fc").val(fc);
				$("#selectCategory").show();
			}
			$.getJSON(
				"./findAllthesauriWordReferenceLieBiao.do",
				{
					page : curr || 1,
					text : $("#nameZh2").val(),
					fc	:$("#fc").val(),
					type :1,
					wordClasses : $("#wordClasses").val()
				},
				function(res) {
					//此处仅仅是为了演示变化的内容
					var titleKey = res.keys[0];
					var titleText='<th width="5%">序号</th><th width="10%">主题款目词</th><th width="10%">英文名称</th>';
					for(var tk in titleKey){
					    titleText += '<th >'+titleKey[tk]+'</th>';
					} 
					titleText += '<th width="6%">可操作</th>';
					$("#trTitle").html(titleText);
					var lieBiaoThesauriWordReference = "";
					$("#lieBiaoThesauriWordReference").html("");
					if (res.listsize > 0) {
						$("#dataNull2").html("");
					} else {
						$("#dataNull2").html("<span class='subtitle' style='font-size: 15px;'>数据为空!</span>");
						$("#trTitle").html("");
					}
					var map = {};
					for ( var j = 0; j < res.listsize; j++) {
						for ( var i = 0; i < res.result[j].countsize; i++) {
							var values = map[res.result[j].thesauriWordReference[i].referenceRelationLabel];
							if(values != null && '' != values && undefined != values){
								if(map['count'+res.result[j].thesauriWordReference[i].referenceRelationLabel] < 3 ){
									map[res.result[j].thesauriWordReference[i].referenceRelationLabel] = map[res.result[j].thesauriWordReference[i].referenceRelationLabel]
											+"<button type='button' class='btn btn-default btn-green btn-xs' onclick=addEditThesauriWord('"
											+ res.result[j].thesauriWordReference[i].referenceWordId+"','"+res.result[j].thesauriWordId +"','"+res.result[j].thesauriWordReference[i].referenceRelationLabel+"')  style='margin-top: 5px; margin-right: 5px;'>"
											+ res.result[j].thesauriWordReference[i].referenceWordName
											+ "</button>";
								}
								map['count'+res.result[j].thesauriWordReference[i].referenceRelationLabel] =map['count'+res.result[j].thesauriWordReference[i].referenceRelationLabel]+1;
							}else{
								map[res.result[j].thesauriWordReference[i].referenceRelationLabel] = "<button type='button' class='btn btn-default btn-green btn-xs' onclick=addEditThesauriWord('"
											+ res.result[j].thesauriWordReference[i].referenceWordId+"','"+res.result[j].thesauriWordId +"','"+res.result[j].thesauriWordReference[i].referenceRelationLabel+"')  style='margin-top: 5px; margin-right: 5px;'>"
											+ res.result[j].thesauriWordReference[i].referenceWordName
											+ "</button>";
								map['count'+res.result[j].thesauriWordReference[i].referenceRelationLabel] =1;
							}
						}
						lieBiaoThesauriWordReference += ""
								+ "<tr>"
								+ "<td ><div id='youxuanY' class='panel-body'  align='center'>"
								+ "<span >"
								+ (j + 1)
								+ "</span>"
								+ "</div></td>"
								+ "<td>"
								+ "<div id='youxuanY' class='panel-body'  align='center'>"
								+ "<div class='demo-btn'>"
								+ "<button type='button' class='btn  btn-warning ' onclick=thesauriWordReferenceAddEdit('"
											+ res.result[j].thesauriWordId
											+ "') style='margin-top: 5px; margin-right: 5px;'>"
											+ res.result[j].thesauriWordName
											+ "</button>"
								+ "</div>" + "</div>"
								+ "</td>"
								+ "<td>"
								+ "<div id='youxuanY' class='panel-body'  align='center'>"
								+ "<div class='demo-btn'>";
								if(res.result[j].wordEnglish != null && res.result[j].wordEnglish !=''){
									lieBiaoThesauriWordReference +=  "<button type='button' class='btn  btn-warning ' onclick=thesauriWordReferenceAddEdit('"
																+ res.result[j].thesauriWordId
																+ "') style='margin-top: 5px; margin-right: 5px;'>"
																+ res.result[j].wordEnglish
																+ "</button>";
								}else{
									lieBiaoThesauriWordReference +=  "<button type='button' class='btn  btn-warning ' style='margin-top: 5px; margin-right: 5px;'>无</button>";
								}
								lieBiaoThesauriWordReference +=  "</div>" + "</div>"
								+ "</td>";
								for(var tk in titleKey){
									if(map[tk] != null && '' != map[tk] && undefined != map[tk]){
										lieBiaoThesauriWordReference +="<td id='"+tk+"_"+res.result[j].thesauriWordId+"'>"+map[tk]+"<button type='button' class='btn btn-default btn-blue btn-xs' onclick=wtFindReferenceSave('"+res.result[j].thesauriWordId+"','"+tk+"') style='margin-top: 5px; margin-right: 5px;'>+</button>";
									}else{
										lieBiaoThesauriWordReference +="<td id='"+tk+"_"+res.result[j].thesauriWordId+"'><button type='button' class='btn btn-default btn-blue btn-xs' onclick=wtFindReferenceSave('"+res.result[j].thesauriWordId+"','"+tk+"') style='margin-top: 5px; margin-right: 5px;'>+</button>";
									}
								   
									if (map['count'+tk] > 3) {
										lieBiaoThesauriWordReference += "<button type='button' id='button_"+tk+"_"+res.result[j].thesauriWordId+"' class='btn btn-default btn-xs' name='bianShow' onclick=shouOrHeid('"+tk+"','"+res.result[j].thesauriWordId+"') style='margin-top: 5px; margin-right: 5px; float: right;'>展开</button>";
									}
									lieBiaoThesauriWordReference += "</td >";
								} 
						
	  				lieBiaoThesauriWordReference += "<td>"
								+ "<div  align='center'>"
								+ "<button type='button' style='margin-bottom: 2px;' class='btn btn-default btn-xs'onclick=delThesauriWord("
								+ res.result[j].thesauriWordId
								+ ") >删除</button>"
								/* + "<button type='button'  style='margin-bottom: 2px;'  class='btn btn-default btn-xs'onclick=addEditThesauriWord2("
								+ res.result[j].thesauriWordId
								+ ") >编辑款目词</button>" */
								+ "<button type='button'  style='margin-bottom: 2px;'  class='btn btn-default btn-xs'onclick=thesauriWordReferenceAddEdit("
								+ res.result[j].thesauriWordId
								+ ") >编辑</button>"
								+ "<button type='button'  style='margin-bottom: 2px;'  class='btn btn-default btn-xs' onclick=releaseFindThesauriWord("
								+ res.result[j].thesauriWordId
								+ ") >发布</button>"
								+ "</div>" + "</td>"
								+ "</tr>";
								map={};
					}
	
					$("#lieBiaoThesauriWordReference").append(
							lieBiaoThesauriWordReference);
							$("#count").html("词表总数:"+res.count);
					//$("[name=bianShow]").hide();
					laypage({
						cont : document.getElementById('page3'), //容器。值支持id名、原生dom对象，jquery对象,
						pages : res.pageSize, //总页数
						skip : true, //是否开启跳页
						skin : 'molv', //加载内置皮肤，也可以直接赋值16进制颜色值，如:#c00
						curr : curr || 1,
						last: res.pageSize,
						groups : 6,//连续显示分页数
						jump : function(obj, first) { //触发分页后的回调
							if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
								findAllthesauriWordReferenceLieBiao(obj.curr);
								curr = obj.curr;
								relevanceCurr=obj.curr;
							}
						}
					});
				});
		};
		
		function wtFindReferenceSave(thesauriWordId,source){
			var addwordClasses = $("#wordClasses").val();
			parent.layer.open({
						type : 2,
						area : [ '900px', '600px' ],
						scrollbar : false,
						shadeClose : true,
						fix : false, //不固定
						title : '编辑',
						//maxmin : true,  
						skin : 'layui-layer-rim', //加上边框
						btn : [ '确认','关闭' ],
						content : [ "word-thesaurus-find-ReferenceSave.html?thesauriWordId="+thesauriWordId+"&count="+relevanceCurr+"&source="+source+"&category=2&winName="+window.name+"&wordClasses="+addwordClasses, 'no' ],
						yes : function(index, layer) {
							var iframeWin = parent.window[layer.find('iframe')[0]['name']];
							iframeWin.queRen();
						},
						cancel : function(index) {
						}
					});
		}
			
		
		
function delThesauriWord(id) {
			if (confirm("是否确认删除！！")) {
				$.ajax({
							type : "post",
							url : "./delThesauriWord.do",
							data : {
								"id" : id
							},
							dataType : "json",
							success : function(data) {
								if (data.count < 1) {
									findAllthesauriWordReferenceLieBiao(curr);
									layer.msg('删除成功');
								} else {
									layer.msg('删除失败！有关联项不可删除。请删除关联项后再删除。');
								}
							},
							error : function(data) {
								alert("请求失败");
							}
						});
			}
		}
		function getZtreeClasses(){
			return $("#wordClasses").val();
		}
		
		function generalWordCategoryzTree() {
			layer.open({
				type : 2,
				area : [ '700px', '640px' ],
				fix : false, //不固定
				scrollbar : false,
				shadeClose : true,
				title : '范畴管理',
				//maxmin : true,  
				skin : 'layui-layer-rim', //加上边框
				btn : [ '关闭' ],
				content : [ "word-thesauriWordCategory-zTree.html", 'no' ],
				cancel : function(index) {
				}
			});
		}

		var thesauriWordId2;
		function getthesauriWordId2() {
			return thesauriWordId2;
		}
	
		function thesauriWordReferenceAddEdit(thesauriWordIds) {
			thesauriWordId2 = thesauriWordIds;
			var wordReferenceAddEditClasses = $("#wordClasses").val();
			layer.open({
						type : 2,
						area : [ '868px', '620px' ],
						scrollbar : false,
						shadeClose : true,
						fix : false, //不固定
						title : '编辑参照项',
						//maxmin : true,  
						skin : 'layui-layer-rim', //加上边框
						btn : [ '保存','关闭' ],
						content : [ "word-thesauriWordReference-addEdit.html?winName="+window.name+"&classes="+wordReferenceAddEditClasses,'no' ],
						yes : function(index, layer) {
							var iframeWin = parent.window[layer.find('iframe')[0]['name']];
							iframeWin.Page();

						},
						cancel : function(index) {
							}
					});
		}
	//导出范畴
	function category(){
		/*
		$.ajax({
				type : "post",
				url : "knowledgeEditDataCategory.do",
				data : {},
				dataType : "json",
				async : false,
				success : function(data) {
					
					alert(JSON.stringify(data));
				},
				error : function(data) {
						//parent.layer.msg('请选择款目词');
				}
			});
		*/
		if (confirm("是否确认导出！！")) {
			var _downiframe = $("iframe#_downiframe");
			if (_downiframe.length == 0) {
				_downiframe =$("<iframe id='_downiframe' name='_downiframe' style='display:none'></iframe>").appendTo($("body"));
			}
			_downiframe.attr("src", "knowledgeEditDataCategory.do");
		}
	}
	//导出数据
	function vocabulary(){
		if (confirm("是否确认导出！！")) {
			var _downiframe = $("iframe#_downiframe");
			if (_downiframe.length == 0) {
				_downiframe =$("<iframe id='_downiframe' name='_downiframe' style='display:none'></iframe>").appendTo($("body"));
			}
			_downiframe.attr("src", "knowledgeEditDataVocabulary.do");
		}
	}
	//根据叙词表id导出
	function exportWord(){
	layer.msg('请选择导出格式', {
		  btn: ['xml', 'Excel'],
		  btn1: function(index){
		    layer.close(index);
		    var _downiframe = $("iframe#_downiframe");
			if (_downiframe.length == 0) {
				_downiframe =$("<iframe id='_downiframe' name='_downiframe' style='display:none'></iframe>").appendTo($("body"));
			}
			_downiframe.attr("src", "exportXmlWord.do?wordClasses="+$("#wordClasses").val()+"&type=Xml");
		  },
		  btn2 : function(index) {
		  	var _downiframe = $("iframe#_downiframe");
			if (_downiframe.length == 0) {
				_downiframe =$("<iframe id='_downiframe' name='_downiframe' style='display:none'></iframe>").appendTo($("body"));
			}
			_downiframe.attr("src", "exportExcelWord.do?wordClasses="+$("#wordClasses").val()+"&type=Excel");
			
		  }
		    
		});
	}	
	
	//词表注解导出
	function note(){
		if (confirm("是否确认下载！！")) {
			document.forms['aa'].submit();
		}
	}
	//范畴注解导出
	function scope(){
		if (confirm("是否确认下载！！")) {
			document.forms['bb'].submit();
		}
	}
	function shouOrHeid(wordReference,wordId){
		$.ajax({
				type : "post",
				url : "shouOrHeidWords.do",
				data : {
					"wordReference":wordReference,
					"wordId":wordId
				},
				dataType : "json",
				async : false,
				success : function(data) {
					var wordButton = $("#button_"+wordReference+"_"+wordId).html();
					var tdValue="";
					if("展开" == wordButton ){
						for ( var i = 0; i < data.length; i++) {
							tdValue +='<button type="button" class="btn btn-default btn-green btn-xs" onclick="addEditThesauriWord(\''
									+ data[i].id+'\',\''+wordId+'\',\''+wordReference+'\')"  style="margin-top: 5px; margin-right: 5px;">'
									+ data[i].wordName
									+ '</button>';
						}
						tdValue += '<button type="button" class="btn btn-default btn-blue btn-xs" onclick="wtFindReferenceSave(\''+wordId+'\',\''+wordReference+'\')" style="margin-top: 5px; margin-right: 5px;">+</button>';
						tdValue +='<button type="button" id="button_'+wordReference+'_'+wordId+'" class="btn btn-default btn-xs" name="bianShow" onclick="shouOrHeid(\''+wordReference+'\',\''+wordId+'\')" style="margin-top: 5px; margin-right: 5px; float: right;">收起</button>'
						$("#"+wordReference+"_"+wordId).html(tdValue);
					}else{
						for ( var i = 0; i < 3; i++) {
							tdValue +='<button type="button" class="btn btn-default btn-green btn-xs" onclick="addEditThesauriWord(\''
									+ data[i].id+'\',\''+wordId+'\',\''+wordReference+'\')"  style="margin-top: 5px; margin-right: 5px;">'
									+ data[i].wordName
									+ '</button>';
						}
						tdValue += '<button type="button" class="btn btn-default btn-blue btn-xs" onclick="wtFindReferenceSave(\''+wordId+'\',\''+wordReference+'\')" style="margin-top: 5px; margin-right: 5px;">+</button>';
						tdValue +='<button type="button" id="button_'+wordReference+'_'+wordId+'" class="btn btn-default btn-xs" name="bianShow" onclick="shouOrHeid(\''+wordReference+'\',\''+wordId+'\')" style="margin-top: 5px; margin-right: 5px; float: right;">展开</button>'
						$("#"+wordReference+"_"+wordId).html(tdValue);
					}
				},
				error : function(data) {
						//parent.layer.msg('请选择款目词');
				}
			});
	}
	//单个发布
	function releaseFindThesauriWord(thesauriWordId){
		$.ajax({
				type : "post",
				url : "releaseFindThesauriWord.do",
				data : {
					"thesauriWordId":thesauriWordId,
				},
				dataType : "json",
				success : function(data) {
					if(data[0].data == 'yes'){
						layer.msg('发布成功！');
					}else{
						layer.msg('发布失败！');
					}
					
				},
				error : function(data) {
					layer.msg('请求失败！');
				}
			});
	}
	
	</SCRIPT>

	<?} ?>